import numpy as np
 

# 轮盘赌选择
def roulette_wheel_selection(population, fitness_values):
    # 计算总适应度
    total_fitness = fitness_values.sum()
    
    # 计算选择概率
    probabilities = fitness_values / total_fitness
    
    # 根据概率选择个体
    selected_indices = np.random.choice(len(population), size=len(population), p=probabilities)
    selected_population = [population[i] for i in selected_indices]
    
    return selected_population